package com.example.demo.service;

import com.example.demo.entity.Product;
import com.example.demo.mapper.ProductMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Service
public class ProductService {
    @Autowired
    private ProductMapper productMapper;

    public Product selectProductById(Integer id) {
        return productMapper.selectById(id);
    }

    public Integer insertProduct(Product product) {
        return productMapper.insert(product);
    }

    public Integer deleteProductById(Integer id) {
        return productMapper.deleteById(id);
    }
    public Integer updateProductById(Integer id,Integer number) {
        Product product=new Product();
        product.setId(id);
        product.setNumber(number);
        return productMapper.updateById(product);
    }
    public Integer selectCountWhere(Product product){
        return productMapper.selectCountWhere(product);
    };

    public List<String> selectDistinctName(){
        return productMapper.selectDistinctName();
    };
}
